<?

/**
 * Media Builder class
 * @package framework
 * @update 4/4/2011 9:10:00 PM
 * Copyright (C) 2011 - AdVerit S.A. <www.adverit.com>
 */

class MediaBuilder
{
    private $_uploadDir = "media";
	private $_filenamePrefix = "media_";

    public function &build($mediaName, $type, $opts)
    {
        switch($type)
        {
            case 'gif':;
            case 'jpg':
                 $media = new MediaImage();
                 break;
            case 'swf':
                 $media = new MediaSwf();
                 break;
		}
		$media->name = $mediaName;
		$media->filename = $this->_buildFileName($opts);
		$media->dirPath = DIR_FILE_UPLOAD ."/". $this->_buildFileDir($opts);
		$media->urlPath = $GLOBALS["CONF"]["url"]["dir_file_upload"] ."/".  $this->_buildFileDir($opts);
		$media->setConfig($opts);

		return $media;
	}

	private function _buildFileName($opts)
	{
		return $opts['mediaID'] ."_". $opts['contentID'] .".". $opts['type'];
	}

	private function _buildFileDir($opts)
	{
		return $opts['module'];
	}
}
?>